import edu.sctu.User;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by dell on 2018/5/26.
 */
public class Database {
    public List<User> getUserList(){
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;

        String sql = "select * from t_users";

        // 加载驱动程序
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
                    "root",
                    "123456" // 大家的密码是：123456
            );
        } catch (SQLException e) {
            e.printStackTrace();
        }

        try {
            statement = (Statement) connection.createStatement();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        resultSet = statement.executeQuery(sql);

    }
}
